<template>
<el-pagination
          :current-page="pageIndex"
          :page-sizes="[2, 5, 10, 20]"
          :page-size="pagesize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
        ></el-pagination>
</template>

<script>
export default {
    name:'pagination',
    props:['dataList'],//父组件传入的所有数据
    data(){
        return {
            pageIndex: 1,//当前页
            pagesize: 10,//每页展示数
            total:5,//总条数
            retList:[],
        }
    },
    computed:{
        currentIndex() {
                this.total=this.dataList.length;//设置总条数
                // 计算当前页的数据
                return this.dataList.filter((item, index) => {
                    return (
                        Math.floor(index / this.pageSize) ===
                        this.pageIndex - 1
                    );
                });
            },
    },
    methods:{
        getData(){
            return this.currentIndex;
        },
        sizeChang(){

        }
    }
}
</script>

<style>

</style>